import request from "@/utils/request";

// let user = JSON.parse(window.localStorage.getItem("user"));
// console.log(user);

export function manufacturerBrandList(data = {}, params = {}) {
  return request({
    url: "/frequency/cmanufacture/list",
    method: "post",
    data,
    params,
  });
}
export function getData(dictCode) {
  return request({
    url: "/system/dict/data/" + dictCode,
    method: "get",
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}
export function dictOne(code) {
  return request({
    url: "/system/dict/data/dictOne/" + code,
    method: "post",
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}
// 查询列表
export function getvdataaudiexchangelist(data) {
  return request({
    url: "/api/v1/dataauditExchange/exchangeList",
    method: "post",
    data,
    params: {
      pageNum: data.pageNum,
      pageSize: data.pageSize,
    },
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}
//获取置换兑换详细信息
export function getvdataaudiexchangeById(id) {
  return request({
    url: "/api/v1/dataauditExchange/" + id,
    method: "get",
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}

//导入置换数据
export function importDataAudit(data) {
  return request({
    url: "/frequency/vdataaudiexchange/importDataAudit",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data,
  });
}
//导入返利数据
export function importRebateData(data) {
  return request({
    url: "/frequency/vdataaudiexchange/importRebateData",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data,
  });
}
//下载返利模板
export function exportRebateDataTemplate() {
  return request({
    url: "/frequency/vdataaudiexchange/exportRebateDataTemplate",
    method: "post",
    responseType: "blob",
  });
}
//上传凭证
export function uploadVoucher(data) {
  return request({
    url: "/api/v1/dataauditExchange/uploadVoucher",
    method: "post",
    data,
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}
//审核
export function examine(data) {
  return request({
    url: "/frequency/vdataaudiexchange/examine",
    method: "post",
    data,
  });
}
//撤销
export function revokeById(id) {
  return request({
    url: "/frequency/vdataaudiexchange/revoke/" + id,
    method: "post",
  });
}
//重新上传凭证
export function againUploadVoucher(data) {
  return request({
    url: "/api/v1/dataauditExchange/againUploadVoucher",
    method: "post",
    data,
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}
//导出
export function exportData(data) {
  return request({
    url: "/frequency/vdataaudiexchange/export",
    method: "post",
    data,
  });
}
//导出详情
export function exportDetail(data) {
  return request({
    url: "/frequency/vdataaudiexchange/exportDetail",
    method: "post",
    data,
  });
}
//操作日志
export function getLog(data) {
  return request({
    url: "/api/v1/dataauditExchange/exchangeOperLogList",
    method: "post",
    data,
    params: {
      pageNum: data.pageNum,
      pageSize: data.pageSize,
    },
    headers: {
      user: JSON.parse(window.localStorage.getItem("user")).data,
      iv: JSON.parse(window.localStorage.getItem("user")).iv,
      key: JSON.parse(window.localStorage.getItem("user")).key,
    },
  });
}
